package com.ranjiaqi.threadpool;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @ClassName ExecutorServiceTest
 * @Description TODO
 * @Author hp
 * @Date 2021/6/30 18:11
 * @Version 1.0
 **/
public class ExecutorServiceTest {
    /**
     * Executors类的静态方法 newFixedThreadPool(int 线程个数)
     */
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> submit = service.submit(new SubRunner(100));
        Future<Integer> submit1 = service.submit(new SubRunner(200));
        System.out.println(submit.get());
        System.out.println(submit1.get());
    }
}
